package com.zynn.api.yinian.zuul.filter;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import com.zynn.api.yinian.zuul.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
import org.springframework.stereotype.Component;


/**
 *
 * 网关日志拦截器
 */
@Component
public class PreLoggerFilter extends ZuulFilter {

	@Autowired
	private LogService logService;

	@Override
	public String filterType() {
		return FilterConstants.PRE_TYPE;
	}

	@Override
	public int filterOrder() {
		return 1;
	}

	@Override
	public boolean shouldFilter() {
		return true;
	}

	@Override
	public Object run() {
		logService.handlePreLog(RequestContext.getCurrentContext());
		return null;
	}
}
